package com.mh.example.annotation.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class UserAspect {

	@Pointcut("execution(* com.mh.example.annotation.aop.UserService.add(..))")
	public void point() {
	}

	@Before("point()")
	public void before() {
		System.out.println("Before...");
	}

	@Around("point()")
	public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
		System.out.println("Around Before ...");
		// 执行被增强的目标方法
		proceedingJoinPoint.proceed();
		System.out.println("Around After ...");
	}

}
